package aip.assignment2.view.customer;

import aip.assignment2.persistence.entity.Purchase;
import aip.assignment2.service.PurchaseManager;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author efish
 */
@ManagedBean
@ViewScoped
public class SearchPurchase implements Serializable
{
	@EJB
	private PurchaseManager m_PurchaseManager;
	private Purchase currentPurchase = null;
	//private String currentPurchaseSearchNumber="group60001";
	//private String currentPurchaseSearchSurname="Liu";
	private String currentPurchaseSearchNumber = "";
	private String currentPurchaseSearchSurname = "";
	public String getCurrentPurchaseSearchNumber()
	{
		return currentPurchaseSearchNumber;
	}
	public void setCurrentPurchaseSearchNumber(String currentPurchaseSearchNumber)
	{
		this.currentPurchaseSearchNumber = currentPurchaseSearchNumber;
	}
	public String getCurrentPurchaseSearchSurname()
	{
		return currentPurchaseSearchSurname;
	}
	public void setCurrentPurchaseSearchSurname(String currentPurchaseSearchSurname)
	{
		this.currentPurchaseSearchSurname = currentPurchaseSearchSurname;
	}
	public void setCurrentPurchase(Purchase currentPurchase)
	{
		this.currentPurchase = currentPurchase;
	}
	public Purchase getCurrentPurchase()
	{
		return currentPurchase;
	}
	public Purchase getPurchaseByName(String surname)
	{
		return m_PurchaseManager.getPurchaseBySurname(surname);
	}
	public Purchase getPurchaseByNumber(String number)
	{
		return m_PurchaseManager.getPurchaseByNumber(number);
	}
	//public Purchase getPurchaseByNameAndNumber(String number, String surname)
	public void search()
	{
		currentPurchase = m_PurchaseManager.getPurchaseByNumberAndSurname(currentPurchaseSearchNumber, currentPurchaseSearchSurname);
	}
}
